package cn.itcast.n3_Java线程;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

import static cn.itcast.util.Sleeper.sleep;

/**
 * @program: juc
 * @description:
 * @author: flyduck
 * @create: 2024-08-29 16:39
 **/
@Slf4j(topic = "c.Test20_interrupt方法_打断park的线程")
public class Test20_interrupt方法_打断park的线程 {

    public static void main(String[] args) {
        test3();
    }

    private static void test3(){
        Thread t1 = new Thread(() -> {
            log.debug("park...");
            LockSupport.park();
            log.debug("unpark...");
            log.debug("打断状态：{}", Thread.currentThread().isInterrupted());//打断状态：true
        }, "t1");
        t1.start();

        sleep(1);
        t1.interrupt();
    }
}
